﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ArgusControls
{
	public class FilterTextBox : TextBox
	{
		private TextFilter filter;

		public FilterTextBox()
		{
			this.filter = new TextFilter(int.MinValue, int.MaxValue);
		}

		public TextFilter Filter
		{
			get { return this.filter; }
			set
			{
				if (value == null)
					this.filter = new TextFilter(int.MinValue, int.MaxValue);
				else
					this.filter = value;
			}
		}

		protected override void OnTextInput(TextCompositionEventArgs e)
		{
			if (e.Text.Length != this.filter.Filter(e.Text).Length)
				e.Handled = true;
			base.OnTextInput(e);
		}
	}
}
